// import ApiService from '../axios'
import ApiService from '@/api/interceptor';
import type * as Type from './role.d'

const preFix = '';
export const getRoleConfig = async () => {
  // const { data } = await ApiService.get<Type.Result<Type.RoleListItem>>(preFix + "/auth/perm/list")
  // const { data: resData } = data;
  // return resData;
  const { data } = await ApiService.get<Type.RoleListItem>(preFix + "/auth/perm/list")
  return data
}

export const getRoleList = (data: Type.RoleListParams) => {
  return ApiService.post<Type.RoleListResponse>(preFix + "/auth/role/search", data)
}

export const switchRoleStatus = (data: Type.UpdateRoleStatusParams) => {
  return ApiService.post<null>(preFix + "/auth/role/status/update", data)
}

export const createRole = (data: Type.CreateRoleParams) => {
  return ApiService.post<Type.CreateRoleParams>(preFix + "/auth/role/create", data)
}

export const getRoleData = async (params: Type.CreateRoleRenponse) => {
  const { data } = await ApiService.get<Type.RoleDetailResponse>(preFix + "/auth/role/" + params.id)
  return data
  // return ApiService.get<Type.RoleDetailResponse>(preFix + "/auth/role/" + params)
}

export const updateRole = (data: Type.UpdateRoleParams) => {
  return ApiService.post<null>(preFix + "/auth/role/update", data)
}